package edu.sctu.zhuyingzhi.month201505.day20150530;



import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.HashMap;
/**
 * Created by user11 on 2015/5/17.
 */
public class TextOne extends TextMore {

    HashMap<String, List<String>> city = new HashMap<String, List<String>>();

    public void getTercherInfo() {

        List<Teacher> list = sotrNumber();


        for (int i = 0; i < list.size(); i++) {
            System.out.println("******" + list.get(i).getName() + "******");
            System.out.println("工号：" + list.get(i).getNumber() + "\t职称：" + list.get(i).getTitle() + "\t性别：" + list.get(i).getSex() + "\t课程：" + list.get(i).getLesson());
            System.out.println("******" + list.get(i).getName() + "******");
            System.out.println("所教学生：");

            for (int j = 0; j < list.get(i).getStudent().size(); j++) {
                System.out.println("\t" + list.get(i).getStudent().get(j).getName());
            }

        }


    }

    public List<Student> getStudent(int code, List<Student> list) {
        List<Student> list1 = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getGradle() > code) {
                list1.add(list.get(i));
            }
        }
        return list1;
    }

    public void getCode() {

        List<Teacher> listT = pritCoded();

        List<Student> listS = new ArrayList<>();

        for (int i = 0; i < listT.size(); i++) {
            listS = listT.get(i).getStudent();
        }

        InterMod inter = new InterMod() {
            @Override
            public void method(List<Student> list) {
                List<Student> list1 = getStudent(75, list);
                System.out.println("教授下成绩大于" + 75 + "的学生：");
                for (int i = 0; i < list1.size(); i++) {


                    System.out.print(list1.get(i).getName() + "\t");
                }

            }
        };
        inter.method(listS);

    }

    public void getcourse() {
        List<Student> StudentList = sortStudent();
        List<List> ListAll = new ArrayList<List>();
        List ListAllaccord = new ArrayList<>();

        List ListChinese = new ArrayList<>();
        List ListMath = new ArrayList<>();
        List ListEnglish = new ArrayList<>();
        List ListChemistry = new ArrayList<>();
        List ListPhysics = new ArrayList<>();
        List ListBiology = new ArrayList<>();
        List ListHistory = new ArrayList<>();

        ListAll.add(ListChinese);
        ListAll.add(ListMath);
        ListAll.add(ListEnglish);
        ListAll.add(ListChemistry);
        ListAll.add(ListPhysics);
        ListAll.add(ListBiology);
        ListAll.add(ListHistory);

        ListChinese.add("语文");
        ListMath.add("数学");
        ListEnglish.add("英语");
        ListBiology.add("生物");
        ListHistory.add("历史");
        ListPhysics.add("物理");
        ListChemistry.add("化学");


        for (int i = 0; i < StudentList.size(); i++) {

            for (int j = 0; j < StudentList.get(i).getCourse().size(); j++) {

                if (StudentList.get(i).getCourse().get(j) == "语文")
                    ListChinese.add(StudentList.get(i).getName());
            }

            for (int j = 0; j < StudentList.get(i).getCourse().size(); j++) {

                if (StudentList.get(i).getCourse().get(j) == "数学")
                    ListMath.add(StudentList.get(i).getName());
            }

            for (int j = 0; j < StudentList.get(i).getCourse().size(); j++) {

                if (StudentList.get(i).getCourse().get(j) == "英语")
                    ListEnglish.add(StudentList.get(i).getName());
            }

            for (int j = 0; j < StudentList.get(i).getCourse().size(); j++) {

                if (StudentList.get(i).getCourse().get(j) == "化学")
                    ListChemistry.add(StudentList.get(i).getName());
            }

            for (int j = 0; j < StudentList.get(i).getCourse().size(); j++) {

                if (StudentList.get(i).getCourse().get(j) == "生物")
                    ListBiology.add(StudentList.get(i).getName());
            }

            for (int j = 0; j < StudentList.get(i).getCourse().size(); j++) {

                if (StudentList.get(i).getCourse().get(j) == "物理")
                    ListPhysics.add(StudentList.get(i).getName());
            }

            for (int j = 0; j < StudentList.get(i).getCourse().size(); j++) {

                if (StudentList.get(i).getCourse().get(j) == "历史")
                    ListHistory.add(StudentList.get(i).getName());
            }
        }


        int x = Math.max(ListBiology.size(), Math.max(ListChemistry.size(), Math.max(ListChinese.size(), Math.max(ListEnglish.size(), Math.max(ListHistory.size(), Math.max(ListMath.size(), ListPhysics.size()))))));

        for (int i = 0; i < ListAll.size(); i++) {
            if (ListAll.get(i).size() == x)
                ListAllaccord.add(ListAll.get(i));
        }

        for (int i = 0; i < ListAllaccord.size(); i++) {
            System.out.println("所选课程最多的是：" + ListAllaccord.get(i));
        }

    }

    public void judgeIs_sanhao() {
        List<Student> list1 = sortStudent();
        System.out.println("三好学生为：");
        for (int i = 0; i < list1.size(); i++) {
            if (list1.get(i).is_sanhao == true)
                System.out.println(list1.get(i).getName());
        }

    }

//    public <T> void getList(List<T> list){
//        Iterator<T> it = list.iterator();
//
//        while(it.hasNext()){
//            it.next();
//            if ()
//        }
//    }

    public void addCity() {
        List<String> smallCityC = new ArrayList<>();
        List<String> smallCityB = new ArrayList<>();

        smallCityC.add("龙泉驿区");
        smallCityC.add("锦江区");
        smallCityC.add("青羊区");
        smallCityC.add("金牛区");
        smallCityC.add("成华区");
        smallCityC.add("武侯区");

        smallCityB.add("朝阳区");
        smallCityB.add("东城区");
        smallCityB.add("海淀区");
        smallCityB.add("丰台区");
        smallCityB.add("大兴区");
        smallCityB.add("青羊区");

        city.put("北京市", smallCityB);
        city.put("成都市", smallCityC);

    }

    public void getStudentAdress() {
        List<Student> list1 = sortStudent();
        String c,d,e;                            //中间变量
        int x;
        addCity();
        System.out.println("地址为成都市 青羊区的是");

        Iterator it = city.keySet().iterator();



        while(it.hasNext()) {
            c = (String) it.next();



            if (c == "成都市") {
                Iterator area = city.get(c).iterator();
                while (area.hasNext()) {
                    d = (String) area.next();

                    for (int i = 0; i < list1.size(); i++) {
                        x = list1.get(i).getAdress().lastIndexOf("/");
                        e = list1.get(i).getAdress().substring(0, x);

                        if (e.equals("成都市")) {
                            if (d.equals("青羊区")) {

                                if (list1.get(i).getAdress().substring(x + 1).equals(d))
                                    System.out.println(list1.get(i).getName());
                            }
                        }
                    }
            }
            }
        }
        }

}
